package 笔试.百度;

import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/7-20:01
 * @version:1.0
 * @function:
 */
public class Main02 {
    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        int N = sca.nextInt();
        int K = sca.nextInt();
        int [][] arr = new int[N][N];
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                arr[i][j] = sca.nextInt();
        int M = N*K;
        int [][] result = new int[M][M];
        for (int i = 0; i < M; i++)
            for (int j = 0; j < M; j++)
                result[i][j] = arr[i/K][j/K];

        for (int i = 0; i < M; i++) {
            StringBuilder r = new StringBuilder();
            for (int j = 0; j < M; j++) {
                r.append(result[i][j]);
                if (j<M-1)r.append(" ");
            }
            System.out.println(r);
        }
    }
}
